/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.hpvas.gui.internalframe;

import edu.hpvas.control.Login;
import edu.hpvas.control.PetController;
import edu.hpvas.control.VeterinarianController;
import edu.hpvas.persistence.entity.Person;
import edu.hpvas.persistence.entity.Pet;
import edu.hpvas.persistence.entity.Veterinarian;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author sony
 */
public class vetInfoFrame extends javax.swing.JInternalFrame {

    Veterinarian vet = new Veterinarian();
    ArrayList<Pet> pets = new ArrayList<>();
    /**
     * Creates new form vetInfoFrame
     */
    public vetInfoFrame() {
        initComponents();
        int ancho=900;
         int alto=550;
         setSize(ancho, alto);
         initialize();
         
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        nameJT = new javax.swing.JTextField();
        nameJL = new javax.swing.JLabel();
        lastNameJT = new javax.swing.JTextField();
        lastnameJL = new javax.swing.JLabel();
        birthDateJT = new javax.swing.JTextField();
        birthDateJL = new javax.swing.JLabel();
        birthPlaceJT = new javax.swing.JTextField();
        birthPlaceJL = new javax.swing.JLabel();
        ssNJT = new javax.swing.JTextField();
        ssnJL = new javax.swing.JLabel();
        focusOfPracticeJT = new javax.swing.JTextField();
        specialitiesJT = new javax.swing.JTextField();
        salaryJT = new javax.swing.JTextField();
        graduatedAtJT = new javax.swing.JTextField();
        specialJL = new javax.swing.JLabel();
        focusJL = new javax.swing.JLabel();
        salaryJL = new javax.swing.JLabel();
        graduateJL = new javax.swing.JLabel();
        petPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablePet = new javax.swing.JTable();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "vet Info", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));

        nameJT.setEditable(false);

        nameJL.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        nameJL.setText("NAME");

        lastNameJT.setEditable(false);

        lastnameJL.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lastnameJL.setText("LASTNAME");

        birthDateJT.setEditable(false);

        birthDateJL.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        birthDateJL.setText("BIRTH DATE");

        birthPlaceJT.setEditable(false);

        birthPlaceJL.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        birthPlaceJL.setText("BIRTH PLACE");

        ssNJT.setEditable(false);

        ssnJL.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        ssnJL.setText("SSN");

        focusOfPracticeJT.setEditable(false);
        focusOfPracticeJT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                focusOfPracticeJTMouseClicked(evt);
            }
        });
        focusOfPracticeJT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                focusOfPracticeJTKeyPressed(evt);
            }
        });

        specialitiesJT.setEditable(false);
        specialitiesJT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                specialitiesJTMouseClicked(evt);
            }
        });
        specialitiesJT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                specialitiesJTKeyPressed(evt);
            }
        });

        salaryJT.setEditable(false);
        salaryJT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                salaryJTMouseClicked(evt);
            }
        });
        salaryJT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                salaryJTKeyPressed(evt);
            }
        });

        graduatedAtJT.setEditable(false);
        graduatedAtJT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                graduatedAtJTMouseClicked(evt);
            }
        });
        graduatedAtJT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                graduatedAtJTKeyPressed(evt);
            }
        });

        specialJL.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        specialJL.setText("Specialities");

        focusJL.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        focusJL.setText("Focus Of Practice");

        salaryJL.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        salaryJL.setText("Salary");

        graduateJL.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        graduateJL.setText("Graduated At");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(birthDateJT, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
                            .addComponent(lastNameJT, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(nameJT, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(birthPlaceJT)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(ssNJT, javax.swing.GroupLayout.PREFERRED_SIZE, 259, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addComponent(ssnJL))
                    .addComponent(birthDateJL)
                    .addComponent(lastnameJL)
                    .addComponent(birthPlaceJL)
                    .addComponent(nameJL))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(salaryJT)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(specialitiesJT, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(focusOfPracticeJT)
                    .addComponent(graduatedAtJT, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(focusJL)
                    .addComponent(specialJL)
                    .addComponent(salaryJL)
                    .addComponent(graduateJL))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(focusJL)
                                .addGap(107, 107, 107))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(focusOfPracticeJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(specialitiesJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(specialJL))
                                .addGap(20, 20, 20)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(salaryJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(salaryJL))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(graduatedAtJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(graduateJL)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nameJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(nameJL))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lastNameJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lastnameJL))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(birthDateJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(birthDateJL))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(birthPlaceJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(birthPlaceJL))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ssNJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ssnJL))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        petPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("pets"));

        tablePet.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tablePet);

        javax.swing.GroupLayout petPanelLayout = new javax.swing.GroupLayout(petPanel);
        petPanel.setLayout(petPanelLayout);
        petPanelLayout.setHorizontalGroup(
            petPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(petPanelLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1)
                .addContainerGap())
        );
        petPanelLayout.setVerticalGroup(
            petPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(petPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(petPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(petPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void focusOfPracticeJTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_focusOfPracticeJTMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_focusOfPracticeJTMouseClicked

    private void focusOfPracticeJTKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_focusOfPracticeJTKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_focusOfPracticeJTKeyPressed

    private void specialitiesJTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_specialitiesJTMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_specialitiesJTMouseClicked

    private void specialitiesJTKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_specialitiesJTKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_specialitiesJTKeyPressed

    private void salaryJTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_salaryJTMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_salaryJTMouseClicked

    private void salaryJTKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_salaryJTKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_salaryJTKeyPressed

    private void graduatedAtJTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_graduatedAtJTMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_graduatedAtJTMouseClicked

    private void graduatedAtJTKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_graduatedAtJTKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_graduatedAtJTKeyPressed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel birthDateJL;
    private javax.swing.JTextField birthDateJT;
    private javax.swing.JLabel birthPlaceJL;
    private javax.swing.JTextField birthPlaceJT;
    private javax.swing.JLabel focusJL;
    private javax.swing.JTextField focusOfPracticeJT;
    private javax.swing.JLabel graduateJL;
    private javax.swing.JTextField graduatedAtJT;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField lastNameJT;
    private javax.swing.JLabel lastnameJL;
    private javax.swing.JLabel nameJL;
    private javax.swing.JTextField nameJT;
    private javax.swing.JPanel petPanel;
    private javax.swing.JLabel salaryJL;
    private javax.swing.JTextField salaryJT;
    private javax.swing.JLabel specialJL;
    private javax.swing.JTextField specialitiesJT;
    private javax.swing.JTextField ssNJT;
    private javax.swing.JLabel ssnJL;
    private javax.swing.JTable tablePet;
    // End of variables declaration//GEN-END:variables

    private void initialize() {
        VeterinarianController controller = new VeterinarianController();
        try{
        vet = controller.getVeterinarian(Login.currentPerson);
        
        nameJT.setText(vet.getIdPerson().getName());
        lastNameJT.setText(vet.getIdPerson().getLastName());
        birthDateJT.setText(vet.getIdPerson().getBirthdate().toString());
        birthPlaceJT.setText(vet.getIdPerson().getBirthPlace());
        ssNJT.setText(vet.getIdPerson().getSsn());
        focusOfPracticeJT.setText(vet.getFocusOfPractice());
        specialitiesJT.setText(vet.getSpecialities());
        salaryJT.setText(vet.getSalary().toString());
        graduatedAtJT.setText(vet.getGraduateAt());
        DefaultTableModel modelo = new DefaultTableModel();
        tablePet.setModel(modelo);
        tablePet.setVisible(true);
        modelo.addColumn("Name");
        modelo.addColumn("Specie");
        PetController petC= new PetController();
        pets = petC.petByVeterinarian(vet);
        for(Pet p: pets){
            modelo.addRow(new Object[]{p.getName(),p.getSpecies()
                        });
        }
        }
        catch(NullPointerException e){
            JOptionPane.showMessageDialog(this, "error");
        }
        
    }
}
